package com.model.defaults.actionbar;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionBarItem;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.UserContextName;

public class ModelDefaultActionbarItemsProject {

	public static void createActionBarItemsProjectTask ( Session session,
	                                                     Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;

		KeyValue actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}", GlobalConstants.SERVLET_TASKADD);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKSLIST);
		pojo = new ActionBarItem();
		pojo.setName("BrowseReports");
		pojo.setCaption("Add task");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	public static void createActionBarItemsProjectVersion ( Session session,
	                                                        Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;

		KeyValue actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo("projectId");
		session.save(actionScriptParam);

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}", GlobalConstants.SERVLET_VERSIONADD);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_VERSIONSLIST);
		pojo = new ActionBarItem();
		pojo.setName("BrowseReports");
		pojo.setCaption("Add version");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	public static void createActionBarItemsProjectList ( Session session,
	                                                     Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText(GlobalConstants.SERVLET_PROJECTADD);
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTSLIST);
		pojo = new ActionBarItem();
		pojo.setName("AddProject");
		pojo.setCaption("Add project");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}



	public static void createActionBarItemsProjectOpen ( Session session,
	                                                     Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;

		KeyValue actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}", GlobalConstants.SERVLET_PROJECTUPDATE);
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		pojo = new ActionBarItem();
		pojo.setName("EditDescription");
		pojo.setCaption("Edit project attributes");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}



	public static void createActionBarItemsProjectUpdate ( Session session,
	                                                       Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;
		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTUPDATE);

		KeyValue actionScriptParam = new KeyValue("form", "?");
		session.save(actionScriptParam);

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("javascript");
		actionScript.setActionScriptText("javascript:document.{form}.submit();");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		pojo = new ActionBarItem();
		pojo.setName("update_project");
		pojo.setCaption("Update project attributes");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}



	public static void createActionBarItemsProjectAdd ( Session session,
	                                                    Map <String, UserContextName> userContexts ) {

		UserContextName contextName_1 = null;
		ActionBarItem pojo = null;
		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTADD);

		KeyValue actionScriptParam = new KeyValue("form", "?");
		session.save(actionScriptParam);

		ActionScript actionScript = new ActionScript();
		actionScript.setActionScriptType("javascript");
		actionScript.setActionScriptText("javascript:document.{form}.submit();");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		pojo = new ActionBarItem();
		pojo.setName("saveProject");
		pojo.setCaption("Save new project");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}
}
